<?php

namespace app\common\lib;

class ClassArr
{
    public static function smsClassStat()
    {
        return [
            'ali' => 'app\common\lib\sms\AliSms',
            'baidu' => 'app\common\lib\sms\BaiduSms',
            'jd' => 'app\common\lib\sms\JdSms',
        ];
    }
    public static function upLoadClassStat(){
        return [
            'text'=>'xxx',
            'image'=>'xxx'
        ];
    }
    public static function initClass($type, $classs, $params = [], $needInstance = false)
    {
        //1.如果我们工厂模式调用的方法时静态的.就返回类
        //2.如果不是静态的,就返回对象
        if (!array_key_exists($type,$classs)){
            return false;
        }
        $className = $classs[$type];

        //new ReflectionClass('A')=>建立A 反射类
        //->newInstanceArgs($args)=>相当于实例化A对象
        return $needInstance == true ? (new \ReflectionClass($className))->newInstanceArgs($params):$className;
    }
}